static void
test_get_boolean_with_default (void)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gboolean out = FALSE;
GLogLevelFlags always_fatal_mask;
FALSE,
&out,
&error));
+ g_clear_error (&error);
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
NULL,
"a_boolean_true",
FALSE,
&out,
&error));
+ g_clear_error (&error);
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
"section",
NULL,
FALSE,
&out,
&error));
+ g_clear_error (&error);
/* Restore the old mask. */
g_log_set_always_fatal (always_fatal_mask);
&error));
g_assert_true (out);
+ g_clear_error (&error);
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
"a_fake_section",
"a_boolean_true",
static void
test_get_value_with_default (void)
{
- GError *error = NULL;
- char *out = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autofree char *out = NULL;
GLogLevelFlags always_fatal_mask;
const char *section = "section";
"none",
&out,
&error));
+ g_clear_pointer (&out, g_free);
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
section,
NULL,
"none",
&out,
&error));
+ g_clear_pointer (&out, g_free);
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
section,
NULL,
"something",
&out,
&error));
+ g_clear_pointer (&out, g_free);
/* Restore the old mask. */
g_log_set_always_fatal (always_fatal_mask);
&out,
&error));
g_assert_cmpstr (out, ==, "foo");
+ g_clear_pointer (&out, g_free);
g_assert (ot_keyfile_get_value_with_default (g_keyfile,
section,
&out,
&error));
g_assert_cmpstr (out, ==, "correct");
+ g_clear_pointer (&out, g_free);
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
"a_fake_section",
"no value",
&out,
&error));
+ g_clear_error (&error);
+ g_clear_pointer (&out, g_free);
}
static void
test_libarchive_autocreate_empty (gconstpointer data)
{
TestData *td = (void*)data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
test_libarchive_error_device_file (gconstpointer data)
{
TestData *td = (void*)data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
r = g_test_run();
+ g_clear_object (&td.repo);
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
(void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
g_free (td.tmpd);
#define MAX_BUFFER_SIZE 1000000
gsize i;
int len;
- unsigned char *a = malloc (MAX_BUFFER_SIZE);
- unsigned char *b = malloc (MAX_BUFFER_SIZE);
+ g_autofree unsigned char *a = malloc (MAX_BUFFER_SIZE);
+ g_autofree unsigned char *b = malloc (MAX_BUFFER_SIZE);
g_autoptr(GRand) rand = g_rand_new ();
/* These two buffers produce the same crc32. */